package com.xindaoapp.happypet.adapter;

import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.xindaoapp.happypet.R;
import com.xindaoapp.happypet.bean.User;
import com.xindaoapp.happypet.view.CircleImageView;

public class UserListAdapter extends MyBaseAdapter<User> {

    private final Context mContext;

    public UserListAdapter(Context context, List<User> mList, int resId) {
        super(context, mList, resId);
        this.mContext = context;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent, User t) {
        ViewHolder holder = (ViewHolder) convertView.getTag();
        if (null == holder) {
            holder = new ViewHolder();
            holder.userIcon = (CircleImageView) convertView.findViewById(R.id.persion_icon);
            holder.userName = (TextView) convertView.findViewById(R.id.tv_title);
            convertView.setTag(holder);
        }
        ImageLoader.getInstance().displayImage(t.userface, holder.userIcon);
        holder.userName.setText(t.username);

        return convertView;
    }

    class ViewHolder {
        CircleImageView userIcon;// 用户头像
        TextView userName;// name
    }

}
